clear; clc;
load('data/recsys/movielen100k.mat');

para.tau = 1.01;
para.maxTime = 3600;

[row, col, val] = find(data);
idx = randperm(length(val));

traIdx = idx(1:floor(length(val)*0.5));
tstIdx = idx(ceil(length(val)*0.5): end);

clear idx;

traData = sparse(row(traIdx), col(traIdx), val(traIdx));
traData(size(data,1), size(data,2)) = 0;

%% start testing
para.maxIter = 5000;
para.tol = 1e-2;

%% non-convex
para.tol = 1e-1;

for i = 1:3
    
para.regType = i;
para.maxR = 20;

switch(i)
    case 1
        lambda = 20;
        theta1 = lambda*2;
    case 2
        lambda = 1000;
        theta1 = sqrt(lambda);
    case 3
        lambda = 20;
        theta1 = 1;
end

%% FAST
t = tic;
para.speedup = 1;
[U, S, V, out{3,i}] = FastMatComp( traData, lambda, theta1, para );
Time(3,i) = toc(t);
RMSE(3,i) = MatCompRMSE( U, V, S, row(tstIdx), col(tstIdx), val(tstIdx));

clear U S V t;

save('movielen100krank');

end

clear data i val valIdx tstIdx traIdx col row traData movies Age;
save('movielen100krank');



